﻿using FileService.Domain;
using FileService.Domain.Entities;
using Kogel.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileService.infrastructure
{
    internal class FSRepository : IFSRepository
    {

        private readonly IRepository<UploadedItem> repository;
        public FSRepository(IRepository<UploadedItem> repository)
        {
            this.repository = repository;
        }

        public async Task<int> Add(UploadedItem item)
        {
           return await repository.InsertAsync(item);
        }

        public async Task<UploadedItem> FindFileAsync(long fileSize, string sha256Hash)
        {
           return await repository.QuerySet().Where(u => u.FileSizeInBytes == fileSize && u.FileSHA256Hash == sha256Hash).GetAsync();
        }
    }
}
